/**
 *告警管理
 */
import request from '@/utils/request'

/**
 *
 *  * 请求值：
 *  queryParams: {
 *      pageNum: 1, //当前页数
 *     pageSize: 10, //每页条数
 *     deviceType: undefined, //设备类型
 *     alarmLevel: undefined, //告警等级 对应数据字典 alarm_level 1:一级告警 2:二级告警 3:三级告警
 *     datetime: undefined, //时间间隔选择
 *     deviceName:undefined //传感器名称，模糊查询
 *   }
 *
 *
 *:[
 {
     "alarmId":1,      //  序号
     "alarmTime":"2020-02-24T14:50:42.000+0800",  // 时间
     "alarmItem":30,
     "alarmValue":11,
     "alarmLevel":1,       // 告警等级
     "alarmState":1,      //告警状态
     "alarmThreadhold":2,   // 当前监测值
     "alarmSensorId":1,
     "alarmSensor":{
         },
         "sensorId":1,
         "imei":null,
         "sensorTypeId":1,
         "sensorType":{
             },
             "sensorTypeId":1,
             "typeName":"GNSS",  //传感器类型
             "typeItems":null,
             "typeParams":null
         },
         "monitorDetail":"表面位移",  //监测内容
         "alterSensor":null,
         "deviceId":2,
         "device":{
             "deviceId":2,
             "supplierId":1,
             "supplier":Object{...},
             "deviceType":0,
             "deviceName":"gnss监测仪",   // 传感器名称
             "description":"测试",
             "number":"111",
             "state":1,    // 工作状态
             "isValid":1,
             "pointId":2,
             "point":
                 "pointId":2,
                 "pointName":"点位1",  // 点位名称
                 "lat":22.9421673,   //  纬度
                 "lon":108.3845291,  // 经度
                 "altitude":0,
                 "isValid":1,
                 "repairTimes":0,
                 "target":null
             },
             "joinTime":"2020-02-24T17:50:08.000+0800",
             "onlineTime":"2020-02-24T17:50:10.000+0800",
             "imei":null
         },
         "baseParams":null,
         "monitorItems":[
                 "itemId":1,
                 "itemName":"X偏移",   // 测项
                 "itemUnit":"mm",
                 "itemValue":20,
                 "valueTime":"2020-02-24T17:52:25.000+0800",
                 "sensorId":1,
                 "sensor":null,
                 "threshold1":50,   // 告警阈值1
                 "threshold2":80,   // 告警阈值2
                 "threshold3":100,  // 告警阈值3
                 "keywords":"",
                 "thresholdType":0
             },
                 "itemId":2,
                 "itemName":"Y偏移",
                 "itemUnit":"mm",
                 "itemValue":20,
                 "valueTime":"2020-02-24T17:52:25.000+0800",
                 "sensorId":1,
                 "sensor":null,
                 "threshold1":50,
                 "threshold2":80,
                 "threshold3":100,
                 "keywords":"",
                 "thresholdType":0
             },
             {
                 "itemId":3,
                 "itemName":"Z偏移",
                 "itemUnit":"mm",
                 "itemValue":20,
                 "valueTime":"2020-02-24T17:52:25.000+0800",
                 "sensorId":1,
                 "sensor":null,
                 "threshold1":50,
                 "threshold2":80,
                 "threshold3":100,
                 "keywords":"",
                 "thresholdType":0
             }
         ]
     }
 }
 ],
 */
// 查询告警记录列表
export function listAlarm(query) {
  return request({
    url: '/slope/alarm/list',
    method: 'get',
    params: query
  })
}

/**
 * 请求参数:
 * {
 *		alarmId:''
 * }
 * 返回参数：
 * {code: 200, msg:""}
 */
// 告警处置
export function changeAlarmStatusById(query) {
  return request({
    url: '/slope/alarm/changAlarmStatus',
    method: 'post',
    params: query
  })
}

/**
 * 请求参数:
 * {
 *		alarmId:'[]'
 * }
 * 返回参数：
 * {code: 200, msg:""}
 */
// 告警批量处置
export function changSelectedAlarmStatus(query) {
  return request({
    url: '/slope/alarm/changSelectedAlarmStatus',
    method: 'post',
    params: query
  })
}

/**
 * 返回参数
 *    {
      "msg": "操作成功",
      "code": 200,
      "data": [
        {
          "num": 1,          // 总数
          "alarmLevel": 1    //告警等级  alarmLevel 1:一级告警 2:二级告警 3:三级告警
        },
        {
          "num": 1,
          "alarmLevel": 2
        }
      ]
    }
 *
 */

// 统计首页告警分类
export function indexAlarmSum() {
  return request({
    url: '/slope/alarm/indexAlarmSum',
    method: 'get',
  })
}

/**
 * 请求参数:
 * {
 *		alarmLevel:''  参数类型:Integer
 *	                 告警等级	1:一级告警 2:二级告警 3:三级告警
 * }
 *  返回值: 同 listAlarm 接口返回值
 *
 */
// 根据告警等级显示首页告警列表
export function selectAlarmListByLevel() {
  return request({
    url: '/slope/alarm/selectAlarmListByLevel',
    method: 'get',
  })
}


// 查询告警记录详细
export function getAlarm(alarmId) {
  return request({
    url: '/slope/alarm/' + alarmId,
    method: 'get'
  })
}

// 删除告警记录
export function deleteAlarm(alarmId) {
  return request({
    url: '/slope/alarm/' + alarmId,
    method: 'post',
  })
}

// 导出告警记录
export function exportAlarm(query) {
  return request({
    url: '/slope/alarm/export',
    method: 'get',
    params: query
  })
}

/**
 * 推送记录
 */

// 推送记录
export function listSubscribe(query) {
  return request({
    url: '/slope/detail/list',
    method: 'get',
    params: query
  })
}

// 导出推送记录
export function exportSubscribe(query) {
  return request({
    url: '/slope/detail/export',
    method: 'get',
    params: query
  })
}

// 一键关闭
export function oneClickClose() {
  return request({
    url: '/slope/alarm/oneClickClose',
    method: 'post'
  })
}

// 删除推送记录
export function deleteSubscribe(subscribeDetailIds) {
  return request({
    url: '/slope/detail/' + subscribeDetailIds,
    method: 'post',
  })
}
